<template>
  
    <div class="mui-numbox" data-numbox-step="1" data-numbox-min="1">
      <button class="mui-btn mui-numbox-btn-minus" type="button">-</button>
      <input class="mui-numbox-input" type="number" value="1" @change="amountChange" ref="numBox">
      <button class="mui-btn mui-numbox-btn-plus" type="button">+</button>
    </div>
  
</template>
<script>
import mui from '../../lib/mui/js/mui.min.js'
export default {
  data() {
    return {};
  },
  methods: {
    amountChange(){
      //change事件触发 调用父组件的方法getMount 获取input框的value值
      //操作dom获取 value值 绑定 ref 即可
      // console.log(this.$refs.numBox.value);
        this.$emit("getMount",this.$refs.numBox.value);
    }
  },
  mounted(){
      //初始化数字选择框
      mui('.mui-numbox').numbox();
      console.log(this.max)
  },
  props:['max'],
  watch:{
    //属性监听
    'max':function(newVal,oldVal){
      mui(".mui-numbox").numbox().setOption("max",newVal);
    }
  }
};
</script>
<style lang="scss" scoped>
</style>
